package com.zerui.manager.app.accessauthorization.executer;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.zerui.cola.dto.Response;
import com.zerui.manager.accessauthdevice.domainservice.AccessAuthDeviceRepository;
import com.zerui.manager.accessauthorization.domainservice.AccessAuthRepository;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;

/**
 * @Author wh
 * @create_time 2023-08-23 10:21
 */
@Component
@CatchAndLog
public class AccessAuthDeleteCmdExe {

	@Resource
	private AccessAuthRepository accessAuthRepository;
	@Resource
	private AccessAuthDeviceRepository accessAuthDeviceRepository;

	@Transactional(rollbackFor = Exception.class)
	public Response execute(Long id) {
		accessAuthDeviceRepository.devicesDeleteDistributePermissions(id,null);
		return accessAuthRepository.deleteById(id);
	}
}
